package com.hong.springboot.config;

import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicRefererConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 *
 * 功能描述: motan的配置
 *
 * @param:
 * @return:
 * @auther: csh
 * @date: 2021/2/2 11:47
 */
@Configuration
public class MotanClientConfig {

	/**
	 * 客户端配置
	 * 
	 * @return BasicRefererConfigBean
	 */
	@Bean(name = "clientBasicConfig")
	@ConfigurationProperties(prefix = "motan.client")
	public BasicRefererConfigBean baseRefererConfig() {
		BasicRefererConfigBean config = new BasicRefererConfigBean();
		return config;
	}


	/**
	 * 声明Annotation用来指定需要解析的包名
	 *
	 * @return AnnotationBean
	 */
	@Bean
	@ConfigurationProperties(prefix = "motan.annotation")
	public static AnnotationBean motanAnnotationBean() {
		AnnotationBean motanAnnotationBean = new AnnotationBean();
		return motanAnnotationBean;
	}

	/**
	 * Motan协议配置
	 *
	 * @return ProtocolConfigBean
	 */
	@Bean(name = "motan")
	@ConfigurationProperties(prefix = "motan.protocol")
	public ProtocolConfigBean protocolConfig() {
		ProtocolConfigBean config = new ProtocolConfigBean();
		return config;
	}

	/**
	 * Motan注册中心配置
	 *
	 * @return RegistryConfigBean
	 */
	@Bean(name = "registryConfig")
	@ConfigurationProperties(prefix = "motan.registry")
	public RegistryConfigBean registryConfig() {
		RegistryConfigBean config = new RegistryConfigBean();
		return config;
	}

}